package com.itheima.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.mapper.NursingProjectMapper;
import com.itheima.pojo.NursingProject;
import com.itheima.pojo.NursingProjectResule;
import com.itheima.pojo.PageNursingQueryParam;
import com.itheima.pojo.PageResult;
import com.itheima.service.NursingProjectService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class NursingProjectServiceImpl extends ServiceImpl<NursingProjectMapper, NursingProject> implements NursingProjectService {

    private final NursingProjectMapper nursingProjectMapper;

    @Override
    public PageResult<NursingProject> PageNursinngProjects(PageNursingQueryParam pageNursingQueryParam) {
        PageHelper.startPage(pageNursingQueryParam.getPageNum(),pageNursingQueryParam.getPageSize());
        List<NursingProject> list = nursingProjectMapper.page(pageNursingQueryParam);
        Page<NursingProject> page = (Page<NursingProject>) list;
        PageResult<NursingProject> pageResult = new PageResult<>(page.getTotal(),page.getPageNum(),page.getPages(),page.getResult());
        return pageResult;
    }

    @Override
    public List<NursingProjectResule> selectList() {
        List<NursingProjectResule> list = nursingProjectMapper.allList();
        return list;
    }
}
